package com.shuoyutech.dp.common.framework.repair;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.apache.commons.lang3.StringUtils;

import java.io.IOException;

/**
 * String反序列化转Long
 *
 * @author dyb
 * @date 2019/11/15
 */
public class String2Long extends JsonDeserializer<Long> {

    @Override
    public Long deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        return StringUtils.isNotBlank(p.getText()) ? Long.valueOf(p.getText()) : null;
    }
}
